<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>其他样式</title>
    <style>
        #box1 {
            width: 100px;
            height: 100px;
            background-color: yellow;
            padding: 10px;
        }
    </style>

    <script>
        window.onload = function () {
            var box1 = document.getElementById("box1");
            var btn01 = document.getElementById("btn01");
            var box4 = document.getElementById("box4");

            btn01.onclick = function () {
                //但是返回的值没有px  不包括边框
                alert(box1.clientWidth);

                var op = box1.offsetParent;

                console.log(op);
            };
        }
    </script>
</head>
<body>
<button id="btn01">点我一下</button>
<br/><br/>
<div id="box1"></div>
</body>
</html>